<template>
  <div>
      <h4>角色配资源专区</h4>
      <h5>获取角色id</h5>
      <van-radio-group v-model="postid">
          <van-radio v-for="i in postlist" :key="i" :name="i.id">{{i.name}}</van-radio>
      </van-radio-group>


      <h5>给角色配置资源</h5>
      <van-checkbox-group v-model="ids">
          <van-checkbox :name='j.id' v-for="j in resourcelist" :key="j">{{j.name}}</van-checkbox>
      </van-checkbox-group>
      <h5>继承角色</h5>
      <van-checkbox-group v-model="ids1">
          <van-checkbox v-for="i in postlist" :key="i" :name="i.id">{{i.name}}</van-checkbox>
      </van-checkbox-group>
        <button @click="post_role">提交</button>


  </div>
</template>

<script>
import axios from '../../http/axios'
export default {
    data () {
        return {
            postid:0,   //将要配置的角色
            ids:[],   //资源
            ids1:[],  //继承的角色
            postlist:[],
            userid:localStorage.getItem('userid'),
            resourcelist:[]
        }
    },
    methods: {
        get_post(){
            axios('/posts','get').then(res=>{
                console.log(res);
                this.postlist=res.list
            })
        },
        get_res(){
             axios("/resourse", "get").then((res) => {
        console.log(res);
        this.resourcelist = res.list;

      });
        },
        post_role(){
            axios('/addrole','post',{'ids':this.ids,'ids1':this.ids1,'postid':this.postid}).then(res=>{
                console.log(res)
            })
        }
    },
    mounted () {
        this.get_post()
        this.get_res()
    }
}
</script>

<style>

</style>